package com.imau.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/reqCode")
public class RequestCode extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //request 乱码 编码不一致 流 字符 字节 ->服务器容器 Tomcat ISO8859-1 ASCII美国 8 GBK GB2312 编码
        req.setCharacterEncoding("UTF-8");
        //String uname= req.getParameter("username");

        //tomcat 8 -9 默认utf8
      //  System.out.println(new String(uname.getBytes("ISO-8859-1"),"UTF-8"));

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //username=%E5%BC%A0%E4%B8%89 默认使用URL编码  iso8859-1 tomcat8-
        String uname= req.getParameter("username");

        //硬解码

        System.out.println(uname);
    }
}
